/**
 * �����������˽���Ͷ�����޹�˾ ��Ȩ����
 *
 * �ļ�:cn.bnyrjy.util.WindowUtil.java
 *
 * ����ʱ��:2015-6-10
 *
 * ������:���ڽ�
 */
package com.sxtyxt.util;

import android.view.View;
import android.view.ViewGroup;
import android.view.View.MeasureSpec;

/**
 */
public class WindowUtil {
	
	public static void measureView(View child) {
		ViewGroup.LayoutParams p = child.getLayoutParams();
		if (p == null) {
			p = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.FILL_PARENT,
			        ViewGroup.LayoutParams.WRAP_CONTENT);
		}
		int childWidthSpec = ViewGroup.getChildMeasureSpec(0, 0 + 0, p.width);
		int lpHeight = p.height;
		int childHeightSpec;
		if (lpHeight > 0) {
			childHeightSpec = MeasureSpec.makeMeasureSpec(lpHeight,
			        MeasureSpec.EXACTLY);
		} else {
			childHeightSpec = MeasureSpec.makeMeasureSpec(0,
			        MeasureSpec.UNSPECIFIED);
		}
		child.measure(childWidthSpec, childHeightSpec);
	}

}
